package com.xuecheng.auth.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mr.M
 * @version 1.0
 * @description 测试controller
 * @date 2022/9/27 17:25
 */
@Slf4j
@RestController
public class LoginController {




    @RequestMapping("/login-success")
    public String loginSuccess() {

        return "登录成功";
    }


//    @RequestMapping("/user/{id}")
//    public XcUser getuser(@PathVariable("id") String id) {
//        XcUser xcUser = userMapper.selectById(id);
//        return xcUser;
//    }

    @RequestMapping("/r/r1")
    @PreAuthorize("hasAuthority('select')")//拥有p1权限方可访问
    public String r1() {
        return "访问r1资源";
    }

    @RequestMapping("/r/r2")
    @PreAuthorize("hasAuthority('update')")//拥有p2权限方可访问
    public String r2() {
        return "访问r2资源";
    }



}
